package cn.tedu.ivos.user.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.user.pojo.dto.UserLoginParam;
import cn.tedu.ivos.user.pojo.vo.UserVO;
import cn.tedu.ivos.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.AuthProvider;


@Slf4j
@RestController
@RequestMapping("/v1/user")
public class UserController {
    @Autowired
    UserService userService;//注意：注入的是接口，而不是实现类

    @PostMapping("login")
    public JsonResult login(@RequestBody UserLoginParam userLoginParam) {
        log.debug("用户登录:userLoginParam={}",userLoginParam);
        //调用业务层方法
        //Ctrl去接口 Ctrl+Alt去借口实现类   Ctrl+Shift去方法返回值类
        UserVO userVO = userService.login(userLoginParam);
        //将返回值添加到JsonResult中返回给前端
        return JsonResult.ok(userVO);
    }
}
